/**
 * 详情对话框
 */
var TeamMembersInfoDlg = {
    data: {
        name: "",
        introduction: "",
        addtime: "",
        path: ""
    }
};

layui.use(['form', 'admin', 'ax','laydate','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;
    var upload = layui.upload;


    //让当前iframe弹层高度适应
    //时间选择器
    laydate.render({
        elem: '#addtime' //指定元素
    });
    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/teamMembers/addItem", function (data) {
            Feng.success("添加成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
    });
    upload.render({
        elem: '#imgHead',
        url: '/teamMembers/upload', // 上传接口
        before: function(obj){
            //预读本地文件示例，不支持ie8
            obj.preview(function(index, file, result){
                $('#tp').attr('src', result); //图片链接（base64）
            });
         }
        ,done: function (res) {
            $("#path").val(res.data[0]);
            Feng.success("上传成功");
        },
        error: function () {
            // 请求异常回调
            Feng.error("异常" );
        }
    });
});